#define _CRT_SECURE_NO_WARNINGS 1
#include"game.h"
void InitBoard(char board[ROWS][COLS], int rows, int cols,char ret)
{
	int i = 0;
	for (i = 0;i < rows; i++)
	{
		int j = 0;
		for (j = 0; j < cols; j++)
		{
			board[i][j] = ret;
		}
	}
}
void DisPlayBoard(char board[ROWS][COLS], int row, int col)
{
	printf("0 1 2 3 4 5 6 7 8 9\n");
	int i = 0;
	for (i = 1; i <= row; i++)
	{
		printf("%d ", i);
		int j = 0;
		for (j = 1; j <= col; j++)
		{
			printf("%c ", board[i][j]);
		}
		printf("\n");
	}
}
void PutMain(char board[ROWS][COLS], int row, int col)
{
	int x = 0;
	int y = 0;
	int count = 10;
	
	while (count )
	{
		x = rand() % row + 1;
		y = rand() % col + 1;
		if (board[x][y] != '1')
		{
			board[x][y] = '1';
			count--;
		}
	}
}
int GetMine(char mine[ROWS][COLS], int x, int y)
{
	return (mine[x][y - 1] + mine[x][y + 1] + mine[x - 1][y] + mine[x - 1][y + 1] + mine[x + 1][y - 1] + 
		mine[x + 1][y + 1] + mine[x - 1][y] + mine[x + 1][y] - 8 * '0');



}
void FindMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col)
{
	int x = 0;
	int y = 0;
	int count = 10;
	while (count>0)
	{
		printf("请输入你的坐标；\n");
		scanf("%d %d", &x, &y);
		if (x >= 1 && x <= 9 && y >= 1 && y <= 9)
		{
			if (mine[x][y] == '1')
			{
				printf("你被炸死了\n");
				DisPlayBoard(show, ROW, COL);
				break;
			}
			else
			{
				int  ret = GetMine(mine, x, y);
				show[x][y] = ret + '0';
				count--;
				DisPlayBoard(show, ROW, COL);

			}

		}
		else
			printf("输入超出范围\n");
		if (count == 0)
		{
			printf("成功！\n");
			DisPlayBoard(show, ROW, COL);
		}

	}
}
	